//
//
//      Copyright Timothy Evans 2015    timothy.evans@gsecraif.org
//
//      This file is part of gsecraif.
//
//      gsecraif is free software; you can redistribute it and/or modify
//      it under the terms of the GNU General Public License as published by
//      the Free Software Foundation; either version 3 of the License, or
//      (at your option) any later version.
//
//      See gsecraif.cpp
//
// =====================================================================
//
//! Transpose bits in an 8 x "length" bytes matrix of bits.
//
// Array is 0 to length-1 e.g. 5 bytes is 0 to 4.
// See tech-notes documentation for information on this function
//
// =====================================================================
// 
// Compile with g++

#include "bit_transpose.h"

using namespace std;
void bit_transpose(vector<unsigned char> original, vector<unsigned char>
                   &transposed, unsigned int length, bool compact)
{
int origbitrows=length; // bit rows = number of bytes
int origbitcols=8;

if (compact) {
    origbitrows=8;
    origbitcols=length;
    }

Bitmatrix origmatrix(origbitrows, origbitcols);
Bitmatrix transmatrix(origbitcols, origbitrows);

// set origmatrix compact bytes to contain original bytes:
origmatrix.setcompactbytes(original);
// transpose:
origmatrix.transpose(transmatrix);
// get the bytes and assign to transposed:
transmatrix.getcompactbytes(transposed);
    
}
// End of function
